package com.k12.edu.controller;


import com.k12.edu.entity.SchoolInfo;
import com.k12.edu.service.SchoolInfoService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 学校信息表(SchoolInfo)表控制层
 *
 * @author makejava
 * @since 2025-08-01 11:20:14
 */
@RestController
@RequestMapping
public class SchoolInfoController {
    /**
     * 服务对象
     */
    @Resource
    private SchoolInfoService schoolInfoService;

    /**
     * 分页查询
     *
     * @param schoolInfo 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @GetMapping("getAllSchool")
    public List<SchoolInfo> queryByPage(SchoolInfo schoolInfo) {
        return this.schoolInfoService.queryByPage(schoolInfo);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public SchoolInfo queryById(@PathVariable("id") Integer id) {
        return this.schoolInfoService.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param schoolInfo 实体
     * @return 新增结果
     */
    @PostMapping("saveOneSchool")
    public SchoolInfo add(SchoolInfo schoolInfo) {
        return this.schoolInfoService.insert(schoolInfo);
    }

    /**
     * 编辑数据
     *
     * @param schoolInfo 实体
     * @return 编辑结果
     */
    @PostMapping("updateOneSchool")
    public SchoolInfo edit(@RequestBody SchoolInfo schoolInfo) {
        return this.schoolInfoService.update(schoolInfo);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("deleteSchool")
    public Boolean deleteById(@RequestParam("id") Long id,@RequestParam("tenantId") String tenantId) {
        return this.schoolInfoService.deleteById(id,tenantId);
    }

}

